package com.test.enumtest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 6.代谢状态
 */
public enum EnumSGA6 {

    // 1.体温状况
    ANSWER1_1(1, 1, "37.2-38.3℃"),
    ANSWER1_2(2, 2, "38.4-38.8℃"),
    ANSWER1_4(4, 3, "≥38.8℃"),
    // 2.应激状态持续时间？
    ANSWER2_8(8, 1, "＜3天"),
    ANSWER2_16(16, 2, "3天"),
    ANSWER2_32(32, 3, "＞3天"),
    // 3.强的松使用量？
    ANSWER3_64(64, 1, "＜10mg"),
    ANSWER3_128(128, 2, "10-30mg"),
    ANSWER3_256(256, 3, "＞30mg"),
    ;

    public final int id;
    public final int score;
    public final String name;

    EnumSGA6(int id, int score, String name) {
        this.id = id;
        this.score = score;
        this.name = name;
    }

    /**
     * 获取答案1列表 1.体温状况
     *
     * @return
     */
    public static List<Map<String, Object>> getAnswer1List() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(createMap(1));
        list.add(createMap(2));
        list.add(createMap(4));
        return list;
    }

    /**
     * 获取答案2列表 2.应激状态持续时间？
     *
     * @return
     */
    public static List<Map<String, Object>> getAnswer2List() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(createMap(8));
        list.add(createMap(16));
        list.add(createMap(32));
        return list;
    }

    /**
     * 获取答案3列表 3.强的松使用量？
     *
     * @return
     */
    public static List<Map<String, Object>> getAnswer3List() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(createMap(64));
        list.add(createMap(128));
        list.add(createMap(256));
        return list;
    }

    /**
     * 根据id获取枚举
     *
     * @param id
     * @return
     */
    public static EnumSGA6 get(int id) {
        switch (id) {
            case 1:
                return ANSWER1_1;
            case 2:
                return ANSWER1_2;
            case 4:
                return ANSWER1_4;
            case 8:
                return ANSWER2_8;
            case 16:
                return ANSWER2_16;
            case 32:
                return ANSWER2_32;
            case 64:
                return ANSWER3_64;
            case 128:
                return ANSWER3_128;
            case 256:
                return ANSWER3_256;
            default:
                return null;
        }
    }

    /**
     * 根据id获取分数
     *
     * @param id
     * @return
     */
    public static int getScore(int id) {
        EnumSGA6 en = EnumSGA6.get(id);
        if (en != null) {
            return en.score;
        } else {
            return -1;
        }
    }

    private static Map<String, Object> createMap(int id) {
        Map<String, Object> map = new HashMap<>();
        map.put("id", EnumSGA6.get(id).id);
        map.put("name", EnumSGA6.get(id).name);
        map.put("score", EnumSGA6.get(id).score);
        return map;
    }
}
